/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Animation;

import Game.TurnManager;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

/**
 *
 * @author Kevin
 */
public class DiceGLEventListener implements GLEventListener{
    private GL			gl;			// GL object that performs rendering
    private GLDrawable		glDrawable;		// surface upon which OpenGL is performed
    private GLU			glu;			// GLU object

    final int CANVASX = 200;
    final int CANVASY = 100;

    TurnManager turnManager;

    public DiceGLEventListener()
    {
        turnManager = turnManager.getTurnManager();
    }

    public void init(GLAutoDrawable drawable) {
        glDrawable = drawable;				// initialize the drawable
        gl = drawable.getGL();				// get the current GL object
        glu = new GLU();				// get the current GLU object

        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);    	// set display window color to black
        gl.glMatrixMode(GL.GL_PROJECTION);    		// set projection parameters to 2D

        gl.glLoadIdentity();			    		// sets projection matrix to identity
        glu.gluOrtho2D(0, CANVASX, 0, CANVASY); 	// set coordinate values
									// with vertices (0,0) for lower left corner
    }

    public void display(GLAutoDrawable drawable) {
        for(int i = 0; i < turnManager.getDiceList().size(); i ++)
        {
            turnManager.getDiceList().get(i).drawSquare(gl);
            
        }
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        
    }

    public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) {
        
    }

}
